﻿using Volo.Abp.Domain.Entities.Auditing;

namespace FlyingEye.DeviceMaintenance
{
    /// <summary>
    /// 设备维护项目模型
    /// </summary>
    public class DeviceMaintenanceModel : AuditedEntity<Guid>, IPropertyLoader
    {
#pragma warning disable CS8618 // 在退出构造函数时，不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
        private DeviceMaintenanceModel()
#pragma warning restore CS8618 // 在退出构造函数时，不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
        {
            // autofac 自动调用
        }

        public DeviceMaintenanceModel(
            Guid deviceHostId,
            string deviceName,
            Guid? comeGroupNotificationConfigurationId,
            Guid? comeUserNotificationConfigurationId,
            Action<object, string> lazyLoader)
        {
            DeviceHostId = deviceHostId;
            DeviceName = deviceName;
            ComeGroupNotificationConfigurationId = comeGroupNotificationConfigurationId;
            ComeUserNotificationConfigurationId = comeUserNotificationConfigurationId;
            LazyLoader = lazyLoader;
        }

        /// <summary>
        /// 设备主机 ID
        /// </summary>
        public Guid DeviceHostId { get; set; }

        /// <summary>
        /// 设备逻辑名称
        /// 一台中控下，会挂载多个设备资源号
        /// </summary>
        public string DeviceName { get; set; }

        private List<MaintenanceMemberModel> _maintenanceMembers = null!;

        /// <summary>
        /// 维护成员列表
        /// </summary>
        public List<MaintenanceMemberModel> MaintenanceMembers
        {
            get => this.Load(ref _maintenanceMembers);
            set => _maintenanceMembers = value;
        }

        /// <summary>
        /// COME 组的 ID
        /// </summary>
        public Guid? ComeGroupNotificationConfigurationId { get; set; }

        /// <summary>
        /// COME 用户 ID
        /// </summary>
        public Guid? ComeUserNotificationConfigurationId { get; set; }

        public Action<object, string> LazyLoader { get; }
    }
}
